﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using br.com.SistemaChamados.Model;
using br.com.SistemaChamados.Enum;
using br.com.SistemaChamados.DAO;

namespace br.com.SistemaChamados.Controller
{
    public class StateController
    {

        public EnumGenericState InsertState(State state)
        {
            EnumGenericState stateTransaction = EnumGenericState.GENERIC_STATE_UNKNOW;
            try
            {
                stateTransaction = StateDAO.InsertState(state);
            }
            catch (Exception ex)
            {
                stateTransaction = EnumGenericState.GENERIC_STATE_FAILED;
                throw ex;
            }
            return stateTransaction;
        }

        public EnumGenericState UpdateState(State state)
        {
            EnumGenericState stateTransaction = EnumGenericState.GENERIC_STATE_UNKNOW;
            try
            {
                stateTransaction = StateDAO.UpdateState(state);
            }
            catch (Exception ex)
            {
                stateTransaction = EnumGenericState.GENERIC_STATE_FAILED;
                throw ex;
            }
            return stateTransaction;
        }

        public EnumGenericState DeleteState(State state)
        {
            EnumGenericState stateTransaction = EnumGenericState.GENERIC_STATE_UNKNOW;
            try
            {
                stateTransaction = StateDAO.DeleteState(state);
            }
            catch (Exception ex)
            {
                stateTransaction = EnumGenericState.GENERIC_STATE_FAILED;
                throw ex;
            }
            return stateTransaction;
        }

        public State GetState(State state)
        {
            State ValidateStateSelected = new State();
            try
            {
                ValidateStateSelected = StateDAO.getState(state);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ValidateStateSelected;
        }

        public List<State> GetStates()
        {
            List<State> Returnedlist = new List<State>();

            try
            {
                Returnedlist = StateDAO.getStates();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return Returnedlist;
        }

    }
}